<template>
  <div class=" card">
    <el-form :model="loginForm" :rules="rules" label-width="auto" style="max-width: 800px">
      <el-form-item label="" prop="username">
        <span class="input-msg">手机号</span>
        <el-input class="input" v-model="loginForm.username" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="" prop="password">
        <span class="input-msg">验证码</span>
        <el-input type="password" v-model="loginForm.password" placeholder="请输入"></el-input>
        <span class="getMsg">获取验证码</span>
      </el-form-item>
      <el-form-item>
        <el-button class="btn" type="primary" @click="handleLogin">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { ref} from 'vue'
import { useRouter, } from 'vue-router';
import { useAuthStore } from '@/stores/auth';

const authStore = useAuthStore();
const router = useRouter();

const loginForm = ref({
  username: 'admin',
  password: '123456'
});

const rules = {
  username: [
    { required: true, message: '请输入账号', trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' }
  ]
};



// 登录
const handleLogin = () => {
  authStore.login({
    username: loginForm.value.username,
    password: loginForm.value.password
  }).then(() => {
    router.push('/order');
  });
};
</script>

<style lang="less" scoped>
.card {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 16px 16px 16px 16px;
  .input-msg{
     position: absolute;
     top: 15px;
     z-index: 99;
     left: 20px;
     font-size:14px;
  }

  .getMsg{
    right: 20px;
    color:blue;
    position: absolute;
    font-size:14px;
  }

  :deep(.el-input__wrapper) {
    width: 100%;
    background: #FFFFFF;
    border-radius: 24px;
    border: none;
    padding: 16px 80px;
  }

  .btn {
    width: 100%;
    padding: 28px 0;
    margin:60px 0;
    border-radius: 24px;
    background-color: #242234;
    border: #242234;
  }

}
</style>
